<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/layui/css/layui.css"
	media="all">
<script type="text/javascript" charset="utf-8"
	src="${pageContext.request.contextPath}/layui/layui.js"></script>
<!-- layui/dist/layui.js" charset="utf-8" -->

<!--  <link rel="stylesheet" href="//res.layui.com/layui/dist/css/layui.css"  media="all"> -->
<%--  <link rel="stylesheet" href="${pageContext.request.contextPath}op/layui/css/layui.css"  media="all"> --%>
</head>
<body>
	<form class="layui-form" action="${pageContext.request.contextPath}/UpdateGoodsServlet?good_id=${good.good_id } "
		enctype="multipart/form-data" method="post">
		<br>
		<br>
		<br>
		<!-- <div class="layui-form-item">
			<label class="layui-form-label">商品编号</label>
			<div class="layui-input-block">
				<input type="text" name="good_id" 
					autocomplete="off" class="layui-input" disabled="disabled">
			</div>
		</div> -->

		<div class="layui-form-item">
			<label class="layui-form-label">商品名称</label>
			<div class="layui-input-block">
				<input type="text" name="good_name" placeholder="请输入商品名称" value="${good.good_name}"
					class="layui-input" style="width: 400px;">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">上架日期</label>
				<div class="layui-input-inline">
					<input type="text" name="time" id="date" lay-verify="date" value="${good.time }${good.good_id }"
						placeholder="yyyy-MM-dd" class="layui-input">
				</div>
			</div>
			<!-- 			autocomplete="off" -->
			<div class="layui-inline">
				<label class="layui-form-label">库存数量</label>
				<div class="layui-input-inline">
					<input type="text" name="quantity" lay-verify="url" value="${good.quantity}"
						class="layui-input">
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">销售价格</label>
				<div class="layui-input-inline" style="width: 100px;">
					<input type="text" name="good_price" placeholder="￥" value="${good.good_price }"
						class="layui-input">
				</div>
			</div>
		</div>

		<div class="layui-inline">
			<label class="layui-form-label">商品类型</label>
			<div class="layui-input-inline">

				<select name="type_id" >
					<c:forEach var="it" items="${typeList}">

						<option value="${it.type_id}">${it.type_name}</option>

					</c:forEach>
				</select>
			</div>
		</div>
		<br> <br>
		<div class="layui-form-item">
			<label class="layui-form-label">出厂地址</label>
			<div class="layui-input-inline">
				<select name="supplier">
					<option value="">请选择省</option>
					<option value="浙江">浙江省</option>
					<option value="江西">江西省</option>
					<option value="福建">福建省</option>
				</select>
			</div>
			<div class="layui-input-inline">
				<select name="supplier">
					<option value="${good.good_name }">请选择市</option>
					<option value="杭州">杭州</option>
					<option value="宁波">宁波</option>
					<option value="温州">温州</option>
					<option value="台州">台州</option>
					<option value="绍兴">绍兴</option>
				</select>
			</div>
			<div class="layui-input-inline">
				<select name="supplier">
					<option value="${good.good_name }">请选择县/区</option>
					<option value="西湖区">西湖区</option>
					<option value="余杭区">余杭区</option>
					<option value="临安">临安市</option>
				</select>
			</div>
			<div class="layui-form-mid layui-word-aux"></div>
		</div>

		<div class="layui-form-item layui-form-text"
			style="width: 400px; height: 50px;">
			<label class="layui-form-label">商品展示</label>
			<div class="layui-input-block">
				<input type="file" onchange="show(this)" name="uploadFile" value="${good.picture }"
					class="layui-input" style="width: 200px;">
			</div>
			<img id="img" src=""
				style="margin-left: 110px; float: left; position: absolute;">
		</div>

		<div class="layui-form-item layui-form-text" style="height: 100px;">
		</div>
		<div class="layui-form-item layui-form-text" style="margin-top: 50px;">
			<label class="layui-form-label">商品简介</label>
			<div class="layui-input-block">
				<textarea class="layui-textarea layui-hide" name="good_desc" value="${good.good_desc}"
					 id="LAY_demo_editor"></textarea>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn">确认修改</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

	<script>
	
	 function show(file){
		//获取要显示图片的标签
		var img = document.getElementById('img');
		//实例化一个FileRear对象，用于读取文件
		var reader = new FileReader();
		//读取File对象的数据
		reader.readAsDataURL(file.files[0]);
		reader.onload = function(evt){
			img.width = "180";
			img.height = "180";
			img.src = evt.target.result;
		}
	} 
		layui
				.use(
						[ 'form', 'layedit', 'laydate' ],
						function() {
							var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate;

							//日期
							laydate.render({
								elem : '#date'
							});
							laydate.render({
								elem : '#date1'
							});

							//创建一个编辑器
							var editIndex = layedit.build('LAY_demo_editor');


							//监听提交
							form.on('submit(demo1)', function(data) {
								layer.alert(JSON.stringify(data.field), {
									title : '最终的提交信息'
								})
								return false;
							});

							

							//表单取值
							layui.$('#LAY-component-form-getval').on('click',
									function() {
										var data = form.val('example');
										alert(JSON.stringify(data));
									});

						});
		//Demo
		layui.use('form', function() {
			var form = layui.form;

			//监听提交
			form.on('submit(formDemo)', function(data) {
				layer.msg(JSON.stringify(data.field));
				return false;
			});
		});
	</script>



</body>
</html>